package com.example.goodsserver.dao;

import org.apache.ibatis.annotations.*;

@Mapper
public interface GoodsStockDao {

    @Insert("insert into stock (id, goods_id, quantity) values (#{id}, #{goodsId}, #{quantity})")
    Integer insertGoodsStock(@Param("id") Long id, @Param("goodsId") Long goodsId, @Param("quantity") Integer quantity);

    @Select("select quantity from stock where goods_id = #{goodsId}")
    Integer queryStockByGoodsId(@Param("goodsId") Long goodsId);

    @Update("update stock set quantity = #{quantity} where goods_id = #{goodsId}")
    void updateStockQuantityByGoodsId(@Param("quantity") Integer quantity, @Param("goodsId") Long goodsId);

}